<template>
  <div class="app-item">
    <div class="logo">
      <img src="" alt="" />
      <!-- {{ data.logo }} -->
    </div>
    <div class="desc">
      <div class="cluster-name">{{ data.name }}</div>
      <div class="time">{{ data.desc }}</div>
      <el-button
        type="primary"
        round
        size="small"
        class="linked"
        :class="disconnected ? 'disconnected' : ''"
        >已连接</el-button
      >
      <div class="more">
        <el-dropdown @command="chooseCommand">
          <span class="el-dropdown-link">
            <i class="el-icon-more"></i>
          </span>
          <el-dropdown-menu slot="dropdown">
            <el-dropdown-item command="edit">编辑</el-dropdown-item>
            <el-dropdown-item command="delete">断开</el-dropdown-item>
          </el-dropdown-menu>
        </el-dropdown>
      </div>
    </div>

    <el-dialog
      title="编辑"
      :visible.sync="dialogVisible"
      width="40%"
      :close-on-click-modal="false"
    >
      <el-form ref="form" :model="form" label-width="100px">
        <el-form-item label="系统名称">
          <el-input v-model="form.app_name"></el-input>
        </el-form-item>
        <el-form-item label="容器规格">
          <el-input v-model="form.app_name"></el-input>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button size="small" @click="dialogVisible = false">取 消</el-button>
        <el-button size="small" type="primary" @click="dialogVisible = false"
          >确 定</el-button
        >
      </span>
    </el-dialog>
  </div>
</template>

<script>
export default {
  props: {
    data: {
      type: Object,
      // eslint-disable-next-line vue/require-valid-default-prop
      default: {},
    },
  },
  data() {
    return {
      disconnected: true,
      dialogVisible: false,
      form: {
        app_name: "",
      },
    };
  },
  methods: {
    chooseCommand(e) {
      console.log(e);
      if (e == "edit") {
        console.log("编辑");
        this.dialogVisible = true;
      } else if (e == "delete") {
        console.log("删除");
      }
    },
  },
};
</script>

<style lang="scss" scoped>
.app-item {
  width: 383px;
  height: 282px;
  background: #f5f7fa;
  border-radius: 4px 4px 4px 4px;
  opacity: 1;
  margin-bottom: 24px;
  margin-right: 20px;
  display: flex;
  flex-direction: column;
  .logo {
    width: 383px;
    height: 120px;
    background: #ccc;
    border-radius: 4px 4px 0px 0px;
    opacity: 1;
  }
}

.cluster-name {
  font-size: 16px;
  font-family: Microsoft YaHei UI-Regular, Microsoft YaHei UI;
  font-weight: 400;
  color: #333333;
}

.desc {
  padding: 16px 20px;
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  .more {
    position: absolute;
    right: 10px;
    top: 10px;
    width: 30px;
    height: 20px;
    display: flex;
    justify-content: flex-end;
    font-size: 20px;
    align-self: flex-start;
    i {
      transform: rotate(90deg);
      cursor: pointer;
      color: #666;
    }
  }
}
.time {
  font-size: 12px;
  font-family: Microsoft YaHei UI-Regular, Microsoft YaHei UI;
  font-weight: 400;
  color: #666666;
  margin: 10px 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}

.linked {
  width: 82px;
  height: 28px;
  background: #cee7ff;
  border-radius: 24px 24px 24px 24px;
  position: relative;
  opacity: 1;
  color: #1890ff;
  background: #cee7ff;
  border: none;
  &::before {
    content: "";
    position: absolute;
    left: 5px;
    top: 50%;
    transform: translate(5px, -50%);
    width: 8px;
    height: 8px;
    background: #1890ff;
    opacity: 1;
    border-radius: 50%;
  }
}
.disconnected {
  width: 82px;
  height: 28px;
  background: #ffe3e1;
  border-radius: 24px 24px 24px 24px;
  position: relative;
  color: #f5222d;
  opacity: 1;
  &::before {
    content: "";
    position: absolute;
    left: 5px;
    top: 50%;
    transform: translate(5px, -50%);
    width: 8px;
    height: 8px;
    background: #f5222d;
    opacity: 1;
    border-radius: 50%;
  }
}
</style>
